/*
 * progressbar.c
 *
 *  Created on: 17.04.2010
 *      Author: 123
 */
#include "progressbar.h"
#include <oslib/oslib.h>
#include "lua.h"
#include "Colors.h"
#include "pgeFont.h"
extern char *LoadingInfo;

extern OSL_IMAGE* wait;
LoadingScreen::LoadingScreen() {
	// The loadingscreen is loaded as a thread
	proc = 0;
	thid_ = sceKernelCreateThread("LoadingThread", RunLoadingScreen, 0x18,
			0x10000, 0, NULL);
	// Start the thread
	sceKernelStartThread(thid_, 0, 0);
}
void LoadingScreen::KillLoadingScreen() {
	// shut down the loading screen again.
	sceKernelTerminateDeleteThread(thid_);
	// free the mem space of the images

}
int LoadingScreen::RunLoadingScreen(SceSize args, void *argp) {

	//int alpha=0;
	while (1) {

		oslStartDrawing();
		oslClearScreen(BLACK);
		oslDrawFillRect(50, 140, 440, 120, RGB(255,255,255));
		oslDrawFillRect(50, 140, proc * 4 + 50, 120, RGB(255,0,0));
		oslDrawStringf(200,155,"%s",LoadingInfo);
		//oslSysBenchmarkDisplay();
		oslEndDrawing();

		oslEndFrame();
		oslSyncFrame();
	}
	return 0;
}
